home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic 4 Database How-To
/
Visual Basic 4 Database - How-to (The Waite Group)(1995).iso
/
publist.fr_
/
publist.fr
Wrap
Text File
|
1995-02-12
|
3KB
|
118 lines
VERSION 4.00
Begin VB.Form frmSelectPublisher
BackColor = &H00C0C0C0&
Caption = "Select Publisher"
ClientHeight = 3150
ClientLeft = 1095
ClientTop = 1530
ClientWidth = 4995
BeginProperty Font
name = "MS Sans Serif"
charset = 1
weight = 700
size = 8.25
underline = 0 'False
italic = 0 'False
strikethrough = 0 'False
EndProperty
Height = 3555
Left = 1035
LinkTopic = "Form2"
ScaleHeight = 3150
ScaleWidth = 4995
Top = 1185
Width = 5115
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "Cancel"
Height = 495
Left = 2820
TabIndex = 2
Top = 2460
Width = 1215
End
Begin VB.ListBox List1
Height = 1980
Left = 360
Sorted = -1 'True
TabIndex = 1
Top = 180
Width = 4215
End
Begin VB.CommandButton cmdOK
Caption = "OK"
Default = -1 'True
Height = 495
Left = 1020
TabIndex = 0
Top = 2460
Width = 1215
End
End
Attribute VB_Name = "frmSelectPublisher"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
Const DATABASE_NAME = "D:\VB4\BIBLIO.MDB"
Private Sub Form_Load()
Dim db As Database
Dim rs As Recordset
Dim sql As String
On Error GoTo LoadError
' Open the database and create a recordset with a list of publishers.
Set db = DBEngine.Workspaces(0).OpenDatabase(DATABASE_NAME)
sql = "SELECT [PubID], [Company Name] FROM [Publishers]"
Set rs = db.OpenRecordset(sql)
' Use the recordset to fill the publishers list.
If rs.RecordCount > 0 Then
FillList rs
Else
MsgBox "There are no publishers in the database.", vbCritical
End
End If
Exit Sub
LoadError:
MsgBox Error$, vbCritical
End
End Sub
Private Sub FillList(rs As Recordset)
' Use the recordset passed as the argument to fill the publishers
' list box. Use the publisher name as the text for each item and
' the PubID as the ItemData.
rs.MoveFirst
Do
If Not IsNull(rs![Company Name]) Then List1 _
.AddItem rs![Company Name] Else List1.AddItem ""
List1.ItemData(List1.NewIndex) = rs![PubID]
rs.MoveNext
Loop While Not rs.EOF
End Sub
Private Sub cmdOK_Click()
' If the user has selected a publisher, set the frmMain variable
' to the PubID and hide this form.
If List1.ListIndex > -1 Then
frmMain.SelectedPubID = List1.ItemData(List1.ListIndex)
Hide
Else
MsgBox "You have not selected a publisher", vbExclamation
End If
End Sub
Private Sub List1_DblClick()
cmdOK_Click
End Sub
Private Sub cmdCancel_Click()
' Set the frmMain variable to 0 to indicate that the user cancelled
' without selecting a publisher.
frmMain.SelectedPubID = 0
Hide
End Sub